<?php
//We start by displaying a form where the user can change his/her status
?>
<div id="mainColumn">
	
	<form action="<?php echo $this->baseURL() ?>/status/status/publish/"  method="post">
	<textarea name="status"></textarea>
	<button type="submit">Publish</button>
	</form>
	
	<?php
	$statuses = $this->stream['data'];
	if(empty($statuses)) {
		echo 'pas de status pour le moment';
	} else {
	
	?>
	<ol class="statuses">
	<?php
	
	foreach($statuses as $mun=> $status) {
		//used multiple times (for the picture, pseudo) so we calculate it once
		$authorURL = $this->baseURL().'/status/index/user/pseudo/'.$status['user']['pseudo'].'/';
		?>
	
		<li class="status" id="status<?php echo $status['id'] ?>">
			<a href="<?php echo $authorURL ?>"><img src="<?php echo $this->avatarBaseURL.$status['user']['pseudo'].'.gif' ?>" class="avatarImage" alt="<?php echo $status['user']['pseudo'] ?>" width="44px" height="44px"  /></a>
			<div class="details">
				<span class="author"><a href="<?php echo $authorURL ?>"><?php echo $status['user']['pseudo'] ?></a></span>
				
				<?php
				if($status['private']) echo '<span class="private"></span>';
				?>
				
				<span class="text"><?php echo $this->statusFormatter($status['status']) ?></span>
				<span class="date">
				<a href="<?php echo $this->baseURL().'/status/status/display/id/'.$status['id'].'/' ?>">
				<?php 
					$timeMode = $this->dateFormatter($status['publishedTime']);
					switch ($timeMode['mode']) {
					case 'seconds':
						echo ($timeMode['gap'] == 0)?'right now':($timeMode['gap'] == 1)?'1 second ago':$timeMode['gap'].' seconds ago';
						break;
					case 'minutes':
						echo ($timeMode['gap'] == 1)?'1 minute ago':$timeMode['gap'].' minutes ago';
					break;
					case 'hours':
						echo ($timeMode['gap'] == 1)?'about 1 hour ago':'about '.$timeMode['gap'].' hours ago';
					break;
					case 'date':
						echo $timeMode['day'].'/'.$timeMode['month'].'/'.$timeMode['year'].' '.$timeMode['hours'].':'.$timeMode['minutes'];
					break;
				}
	
				?>
				</a>
				</span>
				<?php
					//If the user is owner of the status, he can delete it
					if($status['user']['id'] == $this->userId) echo '<span class="deleteStatus"><a href="'.$this->baseURL().'/status/status/delete/id/'.$status['id'].'/">Delete</a></span>';
				?>
			</div>
			
		</li>
		<?php
	} //end foreach status
	
	?>
	</ol>
	
	<?php 
		} //end statuses available
	?>
	
</div> <!-- end main column -->

<div id="sideColumn">
<a href="<?php echo $authorURL ?>"><img src="<?php echo $this->avatarBaseURL. $this->stream['user']['pseudo'].'.gif' ?>" class="avatarImage" alt="<?php echo $this->stream['user']['pseudo'] ?>" width="44px" height="44px"  /></a>
<a href="<?php echo $this->baseURL().'/status/index/user/pseudo/'.$this->stream['user']['pseudo'].'/'; ?>" class="userPseudo"><?php echo $this->stream['user']['pseudo'] ?></a>
<ol class="linksList">			
<li><a href="<?php echo $this->baseURL().'/status/index/following/pseudo/'.$this->stream['user']['pseudo'].'/'; ?>"><?php echo $this->stream['follow']['nbFollowing'] ?> following</a></li>
<li><a href="<?php echo $this->baseURL().'/status/index/follower/pseudo/'.$this->stream['user']['pseudo'].'/'; ?>"><?php echo $this->stream['follow']['nbFollowers'] ?> followers</a></li>
<li><a href="">Home</a></li>
<li><a href=""><?php echo '@'.$this->stream['user']['pseudo'] ?></a></li>
</ol>
</div>
